#!/usr/bin/evn python
# -*- coding: utf-8 -*-


from fastapi import FastAPI
from fastapi.openapi.docs import (get_redoc_html, get_swagger_ui_html, get_swagger_ui_oauth2_redirect_html, )
from fastapi.staticfiles import StaticFiles
import pathlib

from starlette.responses import HTMLResponse

app = FastAPI(docs_url=None, openapi_version='3.0.0')
app.mount("/static",
          StaticFiles(directory=f"{pathlib.Path.cwd()}/static"), name="static")


@app.get('/docs', include_in_schema=False)
async def custom_swagger_ui_html():
    return get_swagger_ui_html(
        openapi_url=app.openapi_url,
        title=app.title + " - Swagger UI",
        oauth2_redirect_url=app.swagger_ui_oauth2_redirect_url,
        swagger_js_url="../static/swagger-ui-bundle.js",
        swagger_css_url="../static/swagger-ui.css",
        swagger_favicon_url="https://fastapi.tiangolo.com/img/favicon.png"
    )

# @app.get('/test')
# def test():
#     return HTMLResponse('<h1>Hello World!</h1>')


if __name__ == "__main__":
    import uvicorn
    import os

    app_modeel_name = os.path.basename(__file__).replace(".py", "")
    print(app_modeel_name)
    uvicorn.run(f"{app_modeel_name}:app", host='127.0.0.1', reload=True)
